package com.atldy.commerce.order;

import com.atldy.commerce.commence.goods.DeductGoodsInventory;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * <h2> 订单商品信息 </h2>
 *
 * @Author: li-dong-yang
 * @CreateTime: 2021-11-03 22:27
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "订单商品信息", description = "订单商品信息")
public class OrderInfo {

    @ApiModelProperty("用户地址ID")
    private Long addressId;

    @ApiModelProperty("订单中的商品信息")
    private List<OrderItem> orderItemList;


    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(value = "订单中的单个商品信息", description = "订单中的单个商品信息")
    class OrderItem {

        @ApiModelProperty("商品ID")
        private Long goodsId;

        @ApiModelProperty("商品数量")
        private int count;

        public DeductGoodsInventory toDeductGoodsInventory() {
            return new DeductGoodsInventory(this.goodsId, this.count);
        }

    }

}